<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        //简单的ATM机
        var mony = 100;
        while (out !== 4) {
            var out = parseInt(prompt('1.存钱\n2.取钱\n3.显示余额\n4.退出\n'))
            switch (out) {
                case 1:
                    var cmony = parseInt(prompt('输入存钱数'));
                    if (cmony > 0) {
                        mony += cmony;
                        alert('存入成功');
                    } else {
                        alert('存入失败')
                    }
                    break;
                case 2:
                    var qmony = parseInt(prompt('输入取钱数'));
                    if (qmony < mony && qmony>0) {
                        mony -= qmony;
                        alert('取钱成功');
                        
                    }else if(qmony>mony){
                        alert('余额不足....')
                    }else if(qmony <= 0) {
                        alert('请输入正确金额...');
                    }
                    break;
                case 3:
                    alert('你的余额为' + mony);
                    break;
                case 4:
                    alert('你正在退出...');
                    break;
                default:
                    alert('输入出错....')
            }
        }
    </script>
</body>

</html>